package com.norbitltd.guavaleaves.java.lang;

import com.google.common.base.Predicate;

public class ShortPredicates {
/**
 * Returns a predicate which checks whether the predicate argument is greater than a given short value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is greater than s, false otherwise
 */
public static Predicate<Short> isGreaterThan(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input > s;
		}
	};
}

/**
 * Returns a predicate which checks whether the predicate argument is greater than or equal to a given short value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is greater than or equal to s, false otherwise
 */
public static Predicate<Short> isGreaterOrEqualThan(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input >= s;
		}
	};
}

/**
 * Returns a predicate which checks whether the predicate argument is lower than a given short value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is lower than s, false otherwise
 */
public static Predicate<Short> isLowerThan(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input < s;
		}
	};
}

/**
 * Returns a predicate which checks whether the predicate argument is lower that or equal to than a given short value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is lower than or equal to s, false otherwise
 */
public static Predicate<Short> isLowerOrEqualThan(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input <= s;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is equal to a given int value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is equal to s, false otherwise
 */
public static Predicate<Short> isEqual(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input == s;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is not equal to a given int value
 * @param s Value to compare the predicate value with
 * @return True if the predicate value is not equal to s, false otherwise
 */
public static Predicate<Short> isNotEqual(final short s) {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input != s;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is a positive int value
 * @return True if the predicate value is greater than 0, false otherwise
 */
public static Predicate<Short> isPositive() {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input > 0;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is a negative int value
 * @return True if the predicate value is lower than 0, false otherwise
 */
public static Predicate<Short> isNegative() {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input < 0;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is a zero-valued int value
 * @return True if the predicate value is equal 0, false otherwise
 */
public static Predicate<Short> isZero() {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input == 0;
		}
	};
}

/**
 * Returns a predicate which check whether the predicate argument is not a zero-valued int value
 * @return True if the predicate value is not equal 0, false otherwise
 */
public static Predicate<Short> isNotZero() {
	return new Predicate<Short>() {
		public boolean apply(Short input) {
			return input != null && input != 0;
		}
	};
}
}
